package zuoye;

public class Student {
	private int id;
	private String name;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	private int age;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(String age) throws AgeException {
		try {
			if (Integer.parseInt(age) < 18 || Integer.parseInt(age) > 25) {
				throw new AgeException();
			}else{
				this.age = Integer.parseInt(age);
			}
		} catch (NumberFormatException e) {
			throw new AgeException();
		}
	}

	public String toString() {
		return "Student [name=" + name + ", age=" + age + "]";
	}

}
